package com.lijinjiang.listener;

import com.lijinjiang.component.JDatePanel;
import com.lijinjiang.component.SelectDatePanel;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

/**
 * @Description 点击顶部按钮监听
 * @Author lijinjiang
 * @Date 2024-12-30 10:52
 */
public class ClickTopButtonListener extends MouseAdapter {
    private final JDatePanel datePanel;

    public ClickTopButtonListener(JDatePanel datePanel) {
        this.datePanel = datePanel;
    }

    @Override public void mouseClicked(MouseEvent e) {
        if (e.getButton() == MouseEvent.BUTTON1) {//左键点击
            Object source = e.getSource();
            SelectDatePanel selectDatePanel = datePanel.getSelectDatePanel();
            if (source == datePanel.getSuperPreviousButton()) {
                selectDatePanel.clickSuperPreviousButtonAction();
            } else if (source == datePanel.getPreviousButton()) {
                selectDatePanel.clickPreviousButtonAction();
            } else if (source == datePanel.getNextButton()) {
                selectDatePanel.clickNextButtonAction();
            } else if (source == datePanel.getSuperNextButton()) {
                selectDatePanel.clickSuperNextButtonAction();
            }
        }
    }
}
